﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Jumpton.Persistent;
using System.Data;

namespace Jumpton.SFA.Server.Entity
{

    [RelationMap("VisitFrequency", typeof(VisitFrequency), "a")]
    [Relation(RelationJoinType.Left, typeof(DictionaryItems), "b", "a", "DictionaryItemID", "TypeID")]
    public class VisitFrequencyView:ObjectRow
    {
        public VisitFrequencyView() { }
        public VisitFrequencyView(DataRow row, ObjectTable parent) : base(row, parent) { }


        [Key("ID", TableAlias = "a")]
        public int ID { get { return (int)GetValue("ID"); } }



        [Field("DomainID", TableAlias = "a")]
        public int DomainID
        {
            get
            {
                return (int)GetValue("DomainID");
            }
           
        }


        [Field("Name", TableAlias = "b")]
        public string CustomerTypeName
        {
            get
            {
                return (string)GetValue("CustomerTypeName");
            }

        }

        [Field("Cycle", TableAlias = "a")]
        public byte Cycle
        {
            get
            {
                return (byte)GetValue("Cycle");
            }
        }

        [Field("Frequency", TableAlias = "a")]
        public int Frequency
        {
            get
            {
                return (int)GetValue("Frequency");
            }
        }

      



        [CalculateField]
        public string CycleName
        {
            get
            {
                string name = "";
                try
                {
                    switch (Cycle)
                    {
                        case 1:
                            {
                                name = "周";
                                break;
                            }
                        case 2:
                            {
                                name = "月";
                                break;
                            }
                        case 3:
                            {
                                name = "年";
                                break;
                            }
                    }
                }
                catch { }
                return name;
            }

        }

   

      
       [Field("IsActive", TableAlias = "a")]
        public bool IsActive
        {
            get
            {
                return (System.Boolean)GetValue("IsActive");
            }
        }

       [Field("IsCheck", TableAlias = "a")]
       public bool IsCheck
       {
           get {
               return (System.Boolean)GetValue("IsCheck");
           }
       }

        [Field("UpdateBy", TableAlias = "a")]
        public string UpdateBy
        {
            get
            {
                return (System.String)GetValue("UpdateBy");
            }
        }

        [Field("LastUpdate", TableAlias = "a")]
        public System.DateTime LastUpdate
        {
            get
            {
                return (System.DateTime)GetValue("LastUpdate");
            }
        }
    }
}
